<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="org.springframework.security.core.context.SecurityContextHolder" %>	
<%@ page import="com.hyd.admin.user.domain.User" %>	
<%@ page import="com.hyd.admin.resource.domain.Resource" %>	
<%@ page import="java.util.List" %>
<%@ page import="java.util.Arrays" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	Object principal = SecurityContextHolder.getContext()
			.getAuthentication().getPrincipal();

	String username;
	if (principal instanceof User) {
		username = ((User) principal).getUsername();
	} else {
		username = principal.toString();
	}
	
	List<Resource> resourceList = ((User) principal).getResourceList();
	request.setAttribute("resourceList",resourceList);
	List<String> ss = Arrays.asList("1","2");
%>
    <div class="navbar navbar-default navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <a class="navbar-brand" href="#">WBRB ERP</a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
          	 <c:forEach items="${resourceList}" var="resource">
	            <li class="dropdown">
	              <a href="#" class="dropdown-toggle" data-toggle="dropdown">${resource.resourceName}<b class="caret"></b></a>
	              <ul class="dropdown-menu">
	              	<c:forEach items="${resource.childResourceList}" var="resource2">
	                	<li><a href="${resource2.resourcePath}">${resource2.resourceName}</a></li>
	                </c:forEach>	
	              </ul>
	            </li>
	         </c:forEach>   
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="./">Logout</a></li>
          </ul>
        </div>
      </div>
    </div>
